home *** CD-ROM | disk | FTP | other *** search
- Path: reno.WPI.EDU!vittohue
- From: Jose Andres Giraldez <vittohue@wpi.edu>
- Newsgroups: comp.lang.c
- Subject: HELP..Need to find why atan2 gives..
- Date: Thu, 1 Feb 1996 01:30:03 -0500
- Organization: Worcester Polytechnic Institute
- Message-ID: <Pine.OSF.3.91.960201012731.27628B-100000@reno.WPI.EDU>
- NNTP-Posting-Host: reno.wpi.edu
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
- I need to find why atan2 gives a number smaller than -180 and greater
- than 180.
- ??????????
-
- /*It works on BIGWPI.wpi.edu*/
- #include <stdio.h>
- #include <float.h>
- #include <math.h>
- #include "/cs/cs1005/problems/problem2/problem2.h"
- int main ()
- {
- int Pi=3.14159, count, n_rows, n_columns;
-
- float limit;
- float temporary;
-
- double degrees[N_MEAS];
- double min_rad_deri;
- double max_rad_deri;
- double derivation[N_MEAS];
- double theta[N_MEAS];
- double radius[N_MEAS];
- double AvgRadius;
- double radius_sum; /* This will find the sum of ALL the radius */
-
-
- /*Set loop for all N_MEAS*/
- for (count = 0; count < N_MEAS; count++)
- {
-
- /*Find all values for theta*/
- radius[count] = sqrt((x[count] * x[count]) + (y[count] * y[count]));
-
- /*Find all values fors radius*/
- theta[count] = atan2(y[count], x[count]);
-
- printf("Here is r: %f and theta: %f\n", radius[count], theta[count]);
-
- /*Find the Sum of all the Radi*/
- radius_sum = radius_sum + radius[count];
-
- /*Use the float.h to see if the radius growing is a problem*/
- /*printf("DEBUG: %f\n", DBL_MAX - radius_sum);*/
- /*THe radius_sum is fine*/
- }
- /*Find the AVG Radius*/
-
- if (radius_sum <0)
- {
- radius_sum = radius_sum * -1;
- }
- else
- {
- AvgRadius = (float) radius_sum / N_MEAS;
- printf("This is the AVG Radius: %f\n",AvgRadius);
- }
-
- /*Find the deviations from the avg radius*/
- for (count=0; count < N_MEAS; count++)
- {
- derivation[count] = (float) AvgRadius - radius[count];
- /*printf("THese are the derivations: %f\n",derivation[count]);*/
- }
- /*Convert theta from radians to degrees*/
- {
- for (count = 0; count<N_MEAS; count++)
- {
- degrees[count] = (double) ((theta[count] * 180)/Pi)+Pi;
- printf("THese are the degrees: %f\n",degrees[count]);
- }
- }
- /*Find the maximum and minimum for the y-axis*/
- {
- float min_rad_deri = 80.0;
- float max_rad_deri = 0.0;
- float temporary;
- for(count= 0; count<N_MEAS; count++)
- {
- temporary=derivation[count];
- if (min_rad_deri > temporary)
- {
- min_rad_deri = temporary;
- }
- temporary=derivation[count];
- if (max_rad_deri < temporary)
- {
- max_rad_deri = temporary;
- }
- }
- printf("The minimum derivation from avg radius: %f\n",min_rad_deri);
- printf("The maximum derivation from avg radius: %f\n",max_rad_deri);
- }
-
- /*Compare the min and max to obtain the limits for the graph*/
- {
- if ((min_rad_deri * -1) > max_rad_deri)
- {
- limit = min_rad_deri;
- }
- if ((min_rad_deri * -1) < max_rad_deri)
- {
- limit = max_rad_deri;
- }
-
- /*Design the graph*/
- {
-
- }
- }
- double degrees =0;
- double radius=0;
- double theta=0;
- Pi=3.14159;
-
- }
-
-
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- --- Jose A. Giraldez "vittohueQwpi.edu" Worcester Polytechnic Institute ---
- --- "I want to die quietly like my | EMSEP CLASS '99 ---
- --- Grandfather, not screaming like | Visual WEB. Programming ---
- --- the people in his car." | SHPE & HSA ---
- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
-